package cn.base.demo2;

import java.util.Scanner;

public class Code03 {
    public static void main(String[] args) {

        // -1 从键盘录入3个蔬菜的名字(字符串), 和价格(小数)
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入3种蔬菜的名称：");
        String v1 = sc.next();
        String v2 = sc.next();
        String v3 = sc.next();
        System.out.print("请输入3种蔬菜的价格：");
        double price1 = sc.nextDouble();
        double price2 = sc.nextDouble();
        double price3 = sc.nextDouble();
        // -2 把价格转为整数, 使用四舍五入. (提示 利用加0 .5 和强转)
        int p1 = (int) price1;
        if (price1 + 0.5 >= p1 + 1) {
            p1 += 1;
        }
        int p2 = (int) price2;
        if (price2 + 0.5 >= p2 + 1) {
            p2 += 1;
        }
        int p3 = (int) price3;
        if (price3 + 0.5 >= p3 + 1) {
            p3 += 1;
        }
        // -3 把转换后的3个蔬菜的价格, 计算平均值, 精确到小数
        double sum = p1 + p2 + p3;
        double average = sum / 3;
        System.out.println(average);
    }
}
